<%--
  Created by IntelliJ IDEA.
  User: Anays
  Date: 2018/6/29
  Time: 20:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<script type="application/javascript">

    var user={name:"aaa",age:"11"};
    ajaxCall("POST","/user/test1",aa,user)
function aa(response){
        alert(response);
    var obj=JSON.parse(response);
    alert(obj);
}
    function ajaxCall(method,url,callBackFunction,data){
        var httprequest=new XMLHttpRequest();
        httprequest.onreadystatechange=function(){
            if(httprequest.readyState==4&&httprequest.status==200){
                callBackFunction(httprequest.responseText);
            }
        }
        httprequest.open(method, url, true);
        httprequest.setRequestHeader("X-Requested-With", "AJAX");
        httprequest.setRequestHeader("Content-Type","application/json,charset=utf-8;")
        console.log(JSON.stringify(data));
        httprequest.send( JSON.stringify(data));
    }

</script>
<body>
<h1>this is login page</h1>
</body>
</html>
